package com.yzcrm.erp.crm.controller;

import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.yzcrm.common.annotation.Permissions;
import com.yzcrm.common.config.paragetter.BasePageRequest;
import com.yzcrm.erp.crm.service.CrmQuotationItemService;
import com.yzcrm.swagger.annotation.ActionApi;
import com.yzcrm.swagger.annotation.Api;
import com.yzcrm.swagger.annotation.Param;
import com.yzcrm.swagger.annotation.Params;
import org.apache.poi.ss.formula.functions.T;


/**
 * Flowers bloom all over the ground, frequent urination urination not enough!
 * IDE: Created with by IntelliJ IDEA.
 * program: yzcrm
 *
 * @author :jones
 * github: https://github.com/luckyrxp
 * email: jonesxr@163.com
 * version: v 1.0
 *
 * <p>
 * <p>
 * date: 2020-08-19
 * time: 16:46
 * description:报价组合 controller
 * Copyright(©) 2020 by Jones
 **/

@Api(remark = "报价项：报价模板")
public class CrmQuotationItemController extends Controller {

    @Inject
    CrmQuotationItemService crmQuotationItemService;

    /**
     * 报价项 :查询报价模板 list
     * type 报价模块从 730 开始
     */
    @Permissions({"crm:quotationComb:index"})
    @ActionApi(summary = "检索报价模板", remark = "检索报价模板")
    @Param(name = "NULL", remark = "不需要传参", dataType = "String")
    public void queryPageList() {
        renderJson(crmQuotationItemService.filterConditionAndGetPageList());
    }

    /**
     * 查询报价模板(字典表)
     */
    @ActionApi(summary = "新增/编辑报价模板时回显选项", remark = "新增/编辑报价模板时回显选项")
    @Param(name = "NULL", remark = "不需要传参", dataType = "String")
    public void queryQuotationTemplate() {
        renderJson(crmQuotationItemService.queryQuotationTemplate());
    }

    /**
     * 报价项 :新增/编辑报价模板
     */
    @Permissions({"crm:quotationComb:save", "crm:quotationComb:update"})
    @ActionApi(summary = "新增/编辑报价模板", remark = "新增/编辑报价模板")
    @Params({
            @Param(name = "quotationItemId", remark = "报价模板id", dataType = "int"),
            @Param(name = "itemOption", remark = "产品选项[1 硬件 2 授权 3 本地部署授权 4 年费 5 人工费]", dataType = "String", required = true),
            @Param(name = "rate", remark = "增值税", dataType = "int", required = true),
            @Param(name = "publicDeploy", remark = "语祯云公有部署[1 选中 2 未选]", dataType = "int", required = true),
            @Param(name = "localDeploy", remark = "语祯云本地部署[1 选中 2 未选]", dataType = "int", required = true),
            @Param(name = "remark", remark = "备注", dataType = "String"),
            @Param(name = "说明", remark = "说明:quotationItemId为0新增,不为0则为编辑", dataType = "int")
    })
    public void saveOrUpdate(BasePageRequest<T> basePageRequest) {
        renderJson(crmQuotationItemService.saveOrUpdate(basePageRequest));
    }

    /**
     * 删除报价模板
     *
     * @param basePageRequest basePageRequest
     */
    @Permissions("crm:quotationComb:delete")
    @ActionApi(summary = "删除报价模板", remark = "删除报价模板")
    @Param(name = "productMaterialId", remark = "产品id", dataType = "int", required = true)
    public void del(BasePageRequest<T> basePageRequest) {
        renderJson(crmQuotationItemService.del(basePageRequest));
    }

}
